package com.laisheng.interview.service.impl;

import com.laisheng.interview.mapper.NotificationMapper;
import com.laisheng.interview.model.Notification;
import com.laisheng.interview.service.NotificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class NotificationServiceImpl implements NotificationService {

    @Autowired
    private NotificationMapper notificationMapper;

    @Override
    public void createNotification(String title, String content, String type, Long accountingInfoId) {
        Notification notification = new Notification();
        notification.setTitle(title);
        notification.setContent(content);
        notification.setType(type);
        notification.setAccountingInfoId(accountingInfoId);
        notification.setIsRead(false);
        notification.setCreateTime(LocalDateTime.now());
        notificationMapper.insert(notification);
    }

    @Override
    public List<Notification> getUnreadNotifications() {
        return notificationMapper.getUnreadNotifications();
    }

    @Override
    public List<Notification> getAllNotifications() {
        return notificationMapper.getAllNotifications();
    }

    @Override
    public void markAsRead(Long id) {
        notificationMapper.markAsRead(id);
    }

    @Override
    public int getUnreadCount() {
        return notificationMapper.getUnreadCount();
    }

    @Override
    public List<Notification> getNotificationsByType(String type) {
        return notificationMapper.getNotificationsByType(type);
    }
    
    @Override
    public List<Notification> getNotificationsByDate(String date) {
        return notificationMapper.getNotificationsByDate(date);
    }
    
    @Override
    public void markMultipleAsRead(List<Long> ids) {
        if (ids != null && !ids.isEmpty()) {
            notificationMapper.markMultipleAsRead(ids);
        }
    }
    
    @Override
    public void markAllAsRead() {
        notificationMapper.markAllAsRead();
    }
} 